package com.yxw.yxnet_cd_center.customer_service.openapicontroller;

import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import com.yxw.yxnet_cd_center.customer_service.vo.MqttServerInfor2AndroidVO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientFiledDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientFiledServiceDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientSendTalkDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientScoreDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientHelpDocuListDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientHelpDocuDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.ClientFinishServiceDTO;
import com.yxw.yxnet_cd_center.customer_service.dto.SubscribeTopicResultDTO;
import com.yxw.yxnet_cd_center.customer_service.service.IYxcscClientFiledServiceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
//import javax.validation.constraints.NotNull;
//import org.springframework.http.server.reactive.ServerHttpRequest;
//import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import javax.servlet.http.HttpServletRequest;
import javax.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 对外Api管理
 * @author hjx
 * @date 2023.09.14
 */
@RestController
@CrossOrigin
@Api(value = "对外Api管理", tags = "对外Api管理")
@Slf4j
public class OpenApiController {

    @Resource
    private IYxcscClientFiledServiceService oIYxcscClientFiledServiceService;
    /*** 
    * 获取Mqtt服务器信息(未加密)
    * @param userId
    * @return MqttServerInforVO
    **/
    @ApiOperation(value ="根据用户Id获取Mqtt服务器信息，以及需要订阅的主题(未加密) ",notes = "此接口用于C端,根据用户Id获取Mqtt服务器信息，以及需要订阅的主题(未加密)")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = MqttServerInfor2AndroidVO.class),})
    @PostMapping("/css/openapi/rec_infor_notsafe")
    public BaseResult getMqttInfoNotSafe(@RequestBody @Valid ClientFiledDTO oClientFiledDTO)
    {
        return oIYxcscClientFiledServiceService.getMqttInfoNotSafe(oClientFiledDTO);
    }      
    /*** 
    * 获取Mqtt服务器信息(加密)
    * @param userId
    * @return MqttServerInforVO
    **/
    @ApiOperation(value ="根据用户Id获取Mqtt服务器信息，以及需要订阅的主题(加密) ",notes = "此接口用于C端,根据用户Id获取Mqtt服务器信息，以及需要订阅的主题(加密)")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = MqttServerInfor2AndroidVO.class),})
    @PostMapping("/css/openapi/rec_infor")
    public BaseResult getMqttInfo(HttpServletRequest httpRequest,@RequestBody @Valid ClientFiledDTO oClientFiledDTO)
    {
        return oIYxcscClientFiledServiceService.getMqttInfo(httpRequest,oClientFiledDTO);
    }    
    /**
     * 客户申请服务
     * @param response 响应
     * @return 
     */
    @ApiOperation(value = "客户申请服务",notes = "此接口用于C端,根据客户信息申请服务")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @PostMapping(value = "/css/openapi/filed_service")
    public BaseResult<String> filedService(@RequestBody @Valid ClientFiledServiceDTO oClientFiledServiceDTO)
    {
        
        return oIYxcscClientFiledServiceService.filedService(oClientFiledServiceDTO);
    }
    /*** 
    * C端MQTT主题订阅结果知会服务器接口
    * @param oClientFiledDTO
    * @return BaseResult
    **/
    @ApiOperation(value =" C端MQTT主题订阅结果知会服务器接口 ",notes = "此接口用于C端,C端MQTT主题订阅结果知会服务器")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = MqttServerInfor2AndroidVO.class),})
    @PostMapping("/css/openapi/subscribe_topic_result")
    public BaseResult subscribeTopicResult(@RequestBody @Valid SubscribeTopicResultDTO oSubscribeTopicResultDTO)
    {
        return oIYxcscClientFiledServiceService.subscribeTopicResult(oSubscribeTopicResultDTO);
    }     
    /**
     * 在线会话内容发送接口
     * @param ClientSendTalkDTO 会话内容
     * @return 
     */
    @ApiOperation(value = "在线会话内容发送接口",notes = "此接口用于C端,在线会话发送接口")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @PostMapping(value = "/css/openapi/send_talk")
    public BaseResult<String> sendTalk(@RequestBody @Valid ClientSendTalkDTO oClientSendTalkDTO)
    {
        return oIYxcscClientFiledServiceService.sendTalk(oClientSendTalkDTO);
    }
    /*** 
    *客户撤回/删除聊天记录接口
    * @param clientId 客服Id
    * @param recordId 聊天记录Id
    * @param operationState 操作状态:0正常的消息,1删除的消息,2撤回的消息
    * @return BaseResult
    **/
    @ApiOperation(value = "客户撤回/删除聊天记录接口",notes = "此接口用于C端,客户撤回/删除聊天记录")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})    
    @GetMapping("/css/openapi/clientRevokeServiceTalkRecord/{clientId}/{recordId}/{operationType}")
    public BaseResult clientRevokeServiceTalkRecord(@PathVariable @NotNull(message = "客户id不能为空") String clientId,@PathVariable @NotNull(message = "聊天记录id不能为空") Long recordId,@PathVariable @NotNull(message = "操作类型不能为空,操作:1删除,2撤回") Integer operationType)
    {
        return oIYxcscClientFiledServiceService.clientRevokeServiceTalkRecord(clientId, recordId, operationType);
    }
    /*** 
    * 客服完成某个服务接口
    * @param userId
    * @return MqttServerInforVO
    **/
    @ApiOperation(value ="客服完成某个服务接口",notes = "此接口用于js端,客服完成某个服务")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @PostMapping("/css/openapi/finish_service")
    public BaseResult ClientFinishService(@RequestBody @Valid ClientFinishServiceDTO oClientFinishServiceDTO)
    {
        return oIYxcscClientFiledServiceService.clientFinishService(oClientFinishServiceDTO.getUserId(), oClientFinishServiceDTO.getSessionId());
    }    
    
    /**
     * 客户对服务的评分接口
     * @param ClientSendTalkDTO 会话内容
     * @return 
     */
    @ApiOperation(value = "客户对服务的评分接口",notes = "此接口用于C端,客户对服务的评分接口")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @PostMapping(value = "/css/openapi/service_score")
    public BaseResult serviceScore(@RequestBody @Valid ClientScoreDTO oClientScoreDTO)
    {
        return oIYxcscClientFiledServiceService.serviceScore(oClientScoreDTO);
    }
    /**
     * 获取常见问题帮助文档列表接口
     * @param ClientSendTalkDTO 帮助文档列表
     * @return 
     */
    @ApiOperation(value = "获取常见问题帮助文档列表接口",notes = "此接口用于C端,获取常见问题帮助文档列表接口")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @PostMapping(value = "/css/openapi/rec_docu_list")
    public BaseResult recDocuList(@RequestBody @Valid ClientHelpDocuListDTO oClientHelpDocuListDTO)
    {
        return oIYxcscClientFiledServiceService.recDocuList(oClientHelpDocuListDTO);
    }
    /**
     * 获取常见问题帮助文档详情接口
     * @param ClientSendTalkDTO 帮助文档内容
     * @return 
     */
    @ApiOperation(value = "获取常见问题帮助文档详情接口",notes = "此接口用于C端,获取常见问题帮助文档详情接口")
    @ApiResponses({@ApiResponse(code = 200,message = "OK",response = BaseResult.class),})
    @PostMapping(value = "/css/openapi/rec_docu_dedail")
    public BaseResult recDocuDedail(@RequestBody @Valid ClientHelpDocuDTO oClientHelpDocuDTO)
    {
        return oIYxcscClientFiledServiceService.recDocuDedail(oClientHelpDocuDTO);
    }       
}